/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.farmcode.core.runtime.event;


import com.farmcode.api.runtime.BaseEvent;
import com.farmcode.api.runtime.FARMCodeContext;
import com.farmcode.api.runtime.Response;
import com.farmcode.api.runtime.metadata.ObjectInfo;
import java.util.List;


/**
 *
 * @author oiprado
 */
public class ObjectsEvent extends BaseEvent<List<ObjectInfo>> {

    @Override
    public Response<List<ObjectInfo>> excecute(FARMCodeContext context) {
      List<ObjectInfo> objectInfos;
        try {
            ObjectInfo type = (ObjectInfo)context.get(FARMCodeContext.CLASS_TYPE);
            objectInfos = databaseExplorerAPI.getObjects(new FARMCodeContext(context), type);
            response.setResult(objectInfos);
        } catch (Exception ex) {
            response.addMessage(ex);
        }
        return response;
    }
}
